﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DebugTools
{
    class ELoad:Visa
    {
        public string _szType;
        public List<String> _ListInitCmd;
        protected string _szCmd;
        protected string _szRet;

        public double _dVolt;
        public double _dCurr;
        public double _dPower;

        public ELoad(string szInsID):base(szInsID)
        {
            _ListInitCmd = new List<string>();
            _szType = "xxxx";
        }

        public virtual bool Init()
        {
            bool bRet = this.QueryType().Contains(_szType);
            if(bRet)
            {
                if (_ListInitCmd.Count > 0)
                {
                    for (int i = 0; i < _ListInitCmd.Count; i++)
                    {
                        _szCmd = _ListInitCmd[i];
                        this.Write(_szCmd);
                    }
                }
            }

            return bRet;
        }

        public virtual double MeasChannelVolt(string Chan)
        {
            _dVolt = 0.0;
            this.Clean();

            _szRet = this.Query(_szCmd);

            double.TryParse(_szRet, out _dVolt);
            return _dVolt;
        }

        public virtual double MeasChannelCurr(string Chan)
        {
            _dCurr = 0.0;
            this.Clean();

            _szRet = this.Query(_szCmd);

            double.TryParse(_szRet, out _dCurr);
            return _dCurr;
        }

        public virtual double MeasChannelPower(string Chan)
        {
            _dPower = 0.0;
            this.Clean();

            _szRet = this.Query(_szCmd);
            double.TryParse(_szRet, out _dPower);
            return _dPower;
        }
    }
}
